export default function date (value: string, type: 'date' | 'datetime' = 'date', defaultValue = '-') {
  if (!value) return defaultValue
  if (typeof value === 'number') {
    const d = new Date(value)
    const f = (t: any) => ('0' + t).slice(-2)
    value = `${d.getFullYear()}/${f(d.getMonth() + 1)}/${f(d.getDate())} ${f(d.getHours())}:${f(d.getMinutes())}:${f(d.getSeconds())}`
  }
  return value.slice(0, type === 'date' ? 10 : undefined)
}
